home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / system-config-printer / gtk_label_autowrap.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  1.1 KB  |  29 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import gtk
  5. from pango import SCALE
  6.  
  7. def set_autowrap(widget):
  8.     if isinstance(widget, gtk.Container):
  9.         children = widget.get_children()
  10.         for i in xrange(len(children)):
  11.             set_autowrap(children[i])
  12.         
  13.     elif isinstance(widget, gtk.Label) and widget.get_line_wrap():
  14.         widget.connect_after('size-allocate', label_size_allocate)
  15.     
  16.  
  17.  
  18. def label_size_allocate(widget, allocation):
  19.     layout = widget.get_layout()
  20.     (lw_old, lh_old) = layout.get_size()
  21.     if lw_old / SCALE == allocation.width:
  22.         return None
  23.     layout.set_width(allocation.width * SCALE)
  24.     (lw, lh) = layout.get_size()
  25.     if lh_old != lh:
  26.         widget.set_size_request(-1, lh / SCALE)
  27.     
  28.  
  29.